/*
 * Project Name spring-boot-tools
 * File Name DemoController
 * Package Name com.huxiaosu.tools.mq
 * Create Time 2024/7/9
 * Create by name：liujie
 */
package com.huxiaosu.tools.mq;

import com.huxiaosu.tools.mq.config.RabbitmqProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description
 *
 * @author liujie
 * @date 2024/7/9 11:17
 */
@Slf4j
@RestController
public class DemoController {

    @Autowired
    private RabbitmqProperties rabbitmqProperties;
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @GetMapping
    public String testSendMessage(){
        log.info(" send msg [nihao]");
        rabbitTemplate.convertAndSend(rabbitmqProperties.getExchange(), rabbitmqProperties.getRequestKey(), "nihao");
        return " send msg [nihao]";
    }
}